using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spinning.Spinning.Entity;
using Microsoft.Xna.Framework;
using Spinning.Spinning.Unitity;

namespace Spinning.Spinning.Scenes.ProcessScene.TopMembers
{
    class Member : BaseEntity
    {
        public AnimationSprite spinnings;
        AnimationSprite names;
        Spinning.Unitity.Constants.PlayerId player;
        Spinning.Unitity.Constants.SpinningType spinning;

        public Spinning.Unitity.Constants.PlayerId Player
        {
            get { return player; }
            set
            {
                player = value;
            }
        }

        public Spinning.Unitity.Constants.SpinningType Spinning
        {
            get { return spinning; }
            set
            {
                spinning = value;
            }
        }

        private void SetPlayer(Constants.PlayerId _player)
        {
            names.SetChangeFrameAnimation(new int[] { Constants.MappingPlayer(_player) });
        }

        private void SetSpinning(Constants.SpinningType _spinning)
        {
            spinnings.SetChangeFrameAnimation(new int[] {Constants.MappingSpinning(_spinning)*2+1 });
        }

        public Member()
        {
            spinnings = new AnimationSprite();
            spinnings.textureName = "item_store/st";
            //spinnings.Scale = new Vector2(0.8f);
            names = new AnimationSprite();
            names.textureName = "role/names";
            Player = Constants.PlayerId.Omega;
            ZIndex = Constants.ui;
        }

        public override void OnLoad()
        {
            //base.OnLoad();
            makeChar(spinnings);
            spinnings.SetAnimation(new Point(3, 4), new int[] { 0 });
            makeChar(names);
        }

        protected override void UpdateSelf(GameTime gameTime)
        {
            base.UpdateSelf(gameTime);

            float x1=-80;
            spinnings.Position = new Vector2(x1,0);
            float x2 = 80;
            names.Position = new Vector2(x2, 0);
            SetPlayer(player);
            SetSpinning(spinning);

        }


        private void makeChar(AnimationSprite _char)
        {
            _char.OnLoad();
            _char.SetAnimation(new Point(1, 3), new int[] { 0 });
            _char.ZIndex = Constants.ui;
            _char.Origin = new Vector2(.5f);
            Attach(_char);
        }



    }
}
